<?php
session_start();
date_default_timezone_set("America/Sao_Paulo");
setlocale(LC_ALL, 'pt_BR');
include "../../../../config/conexao.php";
include "../../../../biblioteca/funcao.php";
extract($_GET);
?>
<html>
    
    <head>
        
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" type="text/css" href="../../../../plugin/estilo.css">
        <link rel="stylesheet" type="text/css" href="../../../../plugin/bootstrap/css/bootstrap-responsive.css">
        <link rel="stylesheet" type="text/css" href="../../../../plugin/bootstrap/css/bootstrap.css"> 
        <script type="text/javascript" src="../../../../plugin/jquery-1.7.2.js"></script>
        <script type="text/javascript" src="../../../../plugin/bootstrap/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="../../../../plugin/funcao.js" /></script>

        <title>Imprimir</title>
        <link href="../../../../base/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
            <!--[if lt IE 9]>
            <script src="plugin/html5.js"></script>
        <![endif]-->
        
    </head>
    
    <body>
        
        
        <div style="padding: 20px;">
            
            <h4>Helpdesk :: Relat&oacute;rio</h4>
            <br>
            <p class="pull-right"><a href="#" onclick="window.print();"><i class="icon-print"></i> Imprimir</a></p>
            <br>
            <table class="table table-striped table-bordered table-hover" >
              <tr>
                <td colspan="4"><big>&Aacute;REAS DE ATUA&ccedil;&atilde;O</big></td>
                <td><big>Quantidade de Itens</big></td>
              </tr>
              <?php
              
                $sql = "SELECT * FROM setor";
                $res = sql($sql);
                while($linha = mysql_fetch_array($res)){ 
                    
                    $sql_chamado = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    LEFT JOIN cliente ON cliente.cli_id=chamado.cli_id
                    LEFT JOIN posto ON posto.pos_id=cliente.pos_id
                    WHERE set_id='{$linha['set_id']}' $onde";
                    $res_chamado = sql($sql_chamado);
                    $num_chamado = mysql_num_rows($res_chamado);
                    
                    if ($num_chamado > 0){
                ?>
              <tr>
                <td colspan="4"><?=$linha['set_nome'];?></td>
                <td width="70"><?=$num_chamado?></td>
              </tr>
              <?php
                    while($linha_chamado = mysql_fetch_array($res_chamado)){
                ?>
              <tr>
                <td width="50"><big><?=$linha_chamado['cha_id'];?></big></td>
                <td width="100">
                <?php echo $linha_chamado['cha_sta_nome'];?></td>
                <td>
                <?php
                echo "{$linha_chamado['cha_nome']}<br>{$linha_chamado['cli_code']} - {$linha_chamado['pos_nome']} {$linha_chamado['cli_guerra']}";
                ?>
                </td>
                <td width="100"><?=todatabr($linha_chamado['cha_data'])." {$linha_chamado['cha_hora']} Z";?></td>
                <td width="70">&nbsp;</td>
              </tr>
              <?php
                    }
                    }
                }
                ?>
            </table>


    </div>
        
    </body>
    
</html>